package com.llho.core.dao.impl;

import java.util.List;

import org.hibernate.HibernateException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.llho.core.dao.CatalogDAO;
import com.llho.core.domain.Catalog;

public class CatalogDAOImpl extends HibernateDaoSupport implements CatalogDAO {

	@Override
	public Catalog getById(Long id) {
		Catalog kq = null;
		try{
			kq = (Catalog)getHibernateTemplate().get(Catalog.class, id);
		}catch(HibernateException e){
			e.printStackTrace();
		}
		return kq;
	}

	@Override
	public List<Catalog> getAll() {
		List<Catalog> kq = null;
		try{
			kq = getHibernateTemplate().find("from Catalog");
		}catch(HibernateException e){
			e.printStackTrace();
		}
		return kq;
	}
	
	

	@Override
	public void update(Catalog entity) {
		try{
			getHibernateTemplate().update(entity);
		}catch(HibernateException e){
			e.printStackTrace();
		}
	}

	@Override
	public void delete(Catalog entity) {
		try{
			getHibernateTemplate().delete(entity);
		}catch(HibernateException e){
			e.printStackTrace();
		}
	}

	@Override
	public void addNew(Catalog entity) {
		try{
			getHibernateTemplate().saveOrUpdate(entity);
		}catch(HibernateException e){
			e.printStackTrace();
		}
	}
}
